﻿using System;
using System.ComponentModel;
using LitJson;
using UnityEngine;

namespace ETModel {
    public static class JsonHelper {
        public static string ToJson(object obj) {
            //return JsonMapper.ToJson(obj);
            //return MongoHelper.ToJson(obj);
            return JsonUtility.ToJson(obj);
        }

        public static T FromJson<T>(string str) {
            //T t = JsonMapper.ToObject<T>(str);
            //T t = MongoHelper.FromJson<T>(str);
            return JsonUtility.FromJson<T>(str);
        }

        public static object FromJson(Type type, string str) {
            //object t = JsonMapper.ToObject(type, str);
            //object t = MongoHelper.FromJson(type, str);
            return JsonUtility.FromJson(str, type);
        }

        public static T Clone<T>(T t) {
            return FromJson<T>(ToJson(t));
        }
    }
}